const { app, BrowserWindow } = require('electron')

// const IPFS = require('ipfs-core')

// let ipfs

// async function open_ipfs() {
//   ipfs = await IPFS.create();
//   const { cid } = await ipfs.add('Hello world')
//   console.log(cid)
// }

// function getText(cid) {
//   console.log('Ha Ha Ha')
// }

function createWindow () {
  // open_ipfs()
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true
    }
  })
  win.webContents.openDevTools()
  win.loadFile('index.html')
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow()
  }
})